package com.atguigu.vod.service.impl;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.vod.model.v20170321.DeleteVideoRequest;
import com.atguigu.vod.service.VodService;
import com.atguigu.vod.utils.ConstantVodUtils;
import com.atguigu.vod.utils.InitVodClient;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @program: guli_parent
 * @description:
 * @author: xuejingjing
 * @create: 2020-12-21 03:53
 **/
public class VodServiceImpl  implements VodService {
    @Override

    //上传文件
    public String uploadAlVideo(MultipartFile file) {
        return null;
    }

    //删除多个阿里云视频的方法
    @Override
    public void removeMoreAliVideos(List videoIdList) {

        //调用初始化对象的方法实现删除
        try {
            //初始化对象
            DefaultAcsClient defaultAcsClient = InitVodClient.initVodClient(ConstantVodUtils.ACCESS_KEY_SECRET, ConstantVodUtils.ACCESS_KEY_ID);
            //创建删除视频request对象
            DeleteVideoRequest request = new DeleteVideoRequest();
            //videoIdList值转换成1,2,3，
            String videoIds = StringUtils.join(videoIdList.toArray(), ",");
            //向request设置视频id
            request.setVideoIds(videoIds);
            defaultAcsClient.getAcsResponse(request);
        } catch (ClientException e) {
            e.printStackTrace();

        }

    }
}
